// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init({
    env: cloud.DYNAMIC_CURRENT_ENV
}
)

const db = cloud.database()

// 云函数入口函数
exports.main = async (event, context) => {
    const requestParam = event.data
    let nickName = requestParam.nickName
    let giftContent = requestParam.giftContent
    let giftIntegral = requestParam.giftIntegral
    let giftImage = requestParam.giftImage
    return await db.collection('bb_gifts').add({
        data: {
            nick_name: nickName,
            gift_content: giftContent,
            gift_integral: Number(giftIntegral),
            gift_image: giftImage
        }
    })  
}